//同步
(function () {
    var onlineBox = U.getId('onlineBox')
    //  console.log(onlineBox)
    var str = ''

    lesson.online.forEach(function (item) {


        str += `<li>
    <div class="top">
        <span class="rj">${item.cont}</span>
        <img src="${item.src}" alt="${item.title}" class="m">
        <p>${item.num}人在学习</p>
    </div>
    <div class="bottom">
        <div class="left">
            <span>${item.title}</span>
            <span class="time">${item.time}课时</span>
        </div>
        <div class="right  ${item.isFree ? '' : 'on'}">${item.isFree ? '免费学习' : '收费学习'}</div>
    </div>
</li>
`
    });
    onlineBox.innerHTML = str;

    //在线测试
    var testBox = U.getId('testBox')
    var str2 = ''
    lesson.test.forEach(function (item) {
        str2 += ` <li>
    <div class="top">
        <span class="rj">${item.cont}</span>
        <img src="${item.src}" alt="" class="m">
        <p>
            <span>${item.num}人已考试</span>
            <span>${item.time}</span>
        </p>
    </div>
    <div class="bottom">
        <div class="left">
            <span>${item.title}</span>
        </div>
        <div class="right">去考试</div>
    </div>
</li>`
    });
    testBox.innerHTML = str2;




    //精品课程
    var goodsBox =U.getId('goodsBox')
    var str3 = '';
    lesson.good.forEach(function (item) {
        str3 += ` <li>
     <div class="top">
         <span class="rj">${item.cont}</span>
         <img src="${item.src}" alt="" class="m">
         <p>${item.num}人在学习</p>
     </div>
     <div class="bottom">
         <div class="left">
             <span>${item.title}</span>
             <span class="time">${item.time}课时</span>
         </div>
         <div class="right  ${item.isFree ? '' : 'on'}" >${item.isFree ? '免费学习' : '收费学习'}</div>
     </div>
 </li>`
    })
    goodsBox.innerHTML = str3;


    
    var top=document.querySelector('.fix .top');
    var fix=document.querySelector('.fix')
    window.onscroll=function(){
      var t=  document.documentElement.scrollTop;
      if(t > 300){
          fix.style.display='block'
      }
      else{
        fix.style.display='none'
      }
    }
     top.onclick=function(){
     var t= document.documentElement.scrollTop;
       clearInterval(top.timer)
       top.timer = setInterval(function () {
            t -= 100;
            document.documentElement.scrollTop = t;

            if (t <= 0) {
                clearInterval(top.timer);
            }
        }, 20);
    }
})()
